package COM.XYS;
import java.util.ArrayList;

public class Demo10Test {

        public static void main(String[] args) {
            ArrayList<Demo10> students = new ArrayList<>();
            students.add(new Demo10(1, "张三"));
            students.add(new Demo10(2, "李四"));
            students.add(new Demo10(3, "王五"));

            System.out.println("初始学生列表: " + students);
            for (int i = 0; i < students.size(); i++) {
                Demo10 s = students.get(i);

                if (s.getName().equals("张三")){
                    s.setName("张三丰");
                }
                if(s.getName().equals("王五")){
                    students.remove(s);
                }
            }
            for (int i = 0; i < students.size(); i++) {
                System.out.println(
                        students.get(i)
                );
            }
        }

    }
